<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 可单独
        Schema::create('trip_order_costs', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户id');
            $table->string('trip_id')->comment('行程业务id');
            $table->integer('trip_type')->default(0)->comment('出行类型 1火车 2飞机 3 酒店');
            $table->integer('trip_no')->default(1)->comment('行程序号 - 1 第一程 - 2 第二程');
            $table->string('order_sn')->comment('订单单号');
            $table->tinyInteger('type')->comment('如:车票,保险费,购票手续费 等');
            $table->decimal('price')->comment('费用单价');
            $table->integer('count')->comment('数量');
            $table->string('name')->comment('收费项如 疫情隔离补贴,指定车厢.指定铺席,维语用语言包');
            $table->string('detail', 50)->default('')->comment('如 二等座，险种，指定的铺席坐席内容等 ');
            $table->string('pay_sn', 32)->default('')->comment('支付单号');
            $table->integer('parent_type')->default(0)->comment('父类型,可能与子类型一致');
            $table->integer('confirm_state')->default(1)->comment('价格确认状态 1 已确认 0 待确认');
            $table->timestamps();
            $table->index(['order_sn', 'user_id'], 'idx_order_user');
            $table->index(['trip_id', 'user_id'], 'idx_trip_user');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('trip_order_costs');
    }
};
